home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Kant Generator Pro 1.2 / src / kode ƒ / kant parser dispatch.c < prev    next >
C/C++ Source or Header  |  1994-11-14  |  1KB  |  58 lines

  1. #include "kant parser dispatch.h"
  2. #include "kant parser.h"
  3. #include "window layer.h"
  4. #include "environment.h"
  5. #include "menus.h"
  6. #include "resource utilities.h"
  7. #include "text twiddling.h"
  8. /* program globals.h is #included in kant parser dispatch.h */
  9.  
  10. enum ErrorTypes ParserDispatch(WindowPtr theWindow)
  11. {
  12.     enum ErrorType    parseError;
  13.     TEHandle        hTE;
  14.     short            index;
  15.     OSErr            oe;
  16.     short            oldRefNum, refNum;
  17.     Boolean            alreadyOpen;
  18.     
  19.     if (!gUseDefault)
  20.         if ((oe=OpenTheResFile(&gModuleFS, &oldRefNum, &refNum, &alreadyOpen, TRUE))!=noErr)
  21.             return kModuleNotFound;
  22.     
  23.     gCustomCursor=FALSE;
  24.     gInProgress=TRUE;
  25.     AdjustMenus();
  26.     DrawMenuBar();
  27.     
  28.     index=GetWindowIndex(theWindow);
  29.     InitTheParser(theWindow, 0, 32767);
  30.     parseError=ParseLoop();
  31.  
  32.     CloseTheResFile(oldRefNum, refNum, alreadyOpen);
  33.  
  34.     if (IndWindowExistsQQ(index))
  35.     {
  36.         hTE=GetWindowTE(theWindow);
  37.         TESelView(hTE);
  38.         AdjustVScrollBar(GetWindowVScrollBar(theWindow), hTE);
  39.     }
  40.     
  41.     gInProgress=FALSE;
  42.     AdjustMenus();
  43.     DrawMenuBar();
  44.     
  45.     switch (parseError)
  46.     {
  47.         case kNoReferenceName:        return kParserNullReferenceName;
  48.         case kBadReference:            return kParserReferenceNotFound;
  49.         case kBadChoiceFormat:        return kParserBadChoiceFormat;
  50.         case kBadOptionalFormat:    return kParserBadOptionalFormat;
  51.         case kNoInstantiations:        return kParserNoInstantiations;
  52.         case kBadBackslash:            return kParserIllegalBackslash;
  53.         case kUserCancelled:        return userCancelErr;
  54.     }
  55.     
  56.     return allsWell;
  57. }
  58.